﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlexFlow.Model
{
    /// <summary>
    /// 表示应用程序定义
    /// </summary>
    public class ApplicationDefine
    {
        /// <summary>
        /// 表示该应用程序绑定的活动类型字符串
        /// </summary>
        public string ActivityType { get; set; }
        /// <summary>
        /// 表示该应用程序绑定的活动的描述
        /// </summary>
        public string ActivityDescription { get; set; }
        /// <summary>
        /// 表示该应用程序前台展示的附加css样式
        /// </summary>
        public string CssClass { get; set; }
        /// <summary>
        /// 表示该应用程序绑定的活动ID，为空表示是默认活动处理程序
        /// </summary>
        public Guid? ProcessId { get; set; }
        /// <summary>
        /// 表示应用程序反射类型的全名称
        /// </summary>
        public String ApplicationClassFullName { get; set; }

        /// <summary>
        /// 取得当前应用程序定义的HashCode
        /// </summary>
        /// <returns>HashCode</returns>
        public override int GetHashCode()
        {
            if (ProcessId == null)
            {
                //末位置0
                return ProcessId.GetHashCode() << 1;
            }
            else
            {
                //末尾置1
                return ActivityType.GetHashCode() << 1 + 1;
            }
        }

        public override bool Equals(object obj)
        {
            ApplicationDefine def = obj as ApplicationDefine;
            if (def == null)
            {
                return false;
            }
            return this.ActivityType == def.ActivityType
                && this.ProcessId == def.ProcessId;
        }
    }
}
